<?php
class Answer_Component_Block_Related extends Phpfox_Component {
    public function process() {
        $aCondition = array('q.id = '. $this->request()->getInt('id'));
        $Question = Phpfox::getService('answer.question')->getForEdit($aCondition);

        $Question = $Question['data'];
        $aCondition = array(
            'category_id = '. $Question['category_id'],
            'q.id <> '. $this->request()->getInt('id')
        );
        $aQuestion = Phpfox::getService('answer.question')->getListNoPage('*', $aCondition, 'rand()', Phpfox::getParam('answer.number_related_questions'));

        if (count($aQuestion['data']) > 0) {
            $this->template()->assign(array(
                    'sHeader' => Phpfox::getPhrase('answer.related_questions'),
                    'aQuestion' => $aQuestion['data'],
                    'view' => 1
                )
            );
            return 'block';
        }
        else {
            $this->template()->assign('view', 0);
        }


    }
}